package com.example.gmailuidemo;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class MyAdapter extends BaseAdapter {
	private Context mContext;
	private List<InfoModel> mList;

	public MyAdapter(Context context, List<InfoModel> list) {
		mContext = context;
		mList = list;
	}

	@Override
	public int getCount() {

		return mList.size();
	}

	@Override
	public Object getItem(int arg0) {

		return mList.get(arg0);
	}

	@Override
	public long getItemId(int position) {

		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		LayoutInflater inflater = LayoutInflater.from(mContext);
		convertView = inflater.inflate(R.layout.dropdown_item, null);
		if (convertView != null) {
			TextView titleView = (TextView) convertView
					.findViewById(R.id.dropdown_title);
			TextView countView = (TextView) convertView
					.findViewById(R.id.dropdown_count);

			titleView.setText(mList.get(position).getTitle());
			countView.setText(mList.get(position).getCount());
		}

		return convertView;
	}

}
